﻿@{
    ViewData["Title"] = "AddClientIndex";
    Layout = null;
}
<html>
<head>
    @* <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="~/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" /> *@

    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>
</head>
<body>
    <!-- 给容器追加 class="layui-form-pane"，即可显示为方框风格 -->


     <form class="layui-form layui-form-pane" action="">
       <div class="layui-form-item">
            <label class="layui-form-label">客户编码</label>
            <div class="layui-input-block">
                <input type="text" name="ClientCode" id="ClientCode" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
                <button class="layui-btn" id="test-btn-other">随机生成</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户名称</label>
            <div class="layui-input-block">
                <input type="text" name="ClientName" autocomplete="Name" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户英文名称</label>
            <div class="layui-input-block">
                <input type="text" name="ClientEnName"  autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户类型</label>
            <div class="layui-input-inline">
                <select name="ClientType" lay-filter="aihao">
                    <option value="请选择">请选择</option>
                    <option value="企业客户">企业客户</option>
                    <option value="个人">个人</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">客户简介</label>
            <div class="layui-input-block">
                <textarea name="ClientDesc" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">客户地址</label>
            <div class="layui-input-block">
                <textarea name="Address"  placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户官网地址</label>
            <div class="layui-input-block">
                <input type="text" name="WebSite"  autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户邮箱地址</label>
            <div class="layui-input-block">
                <input type="text" name="Email" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户电话</label>
            <div class="layui-input-block">
                <input type="text" name="Tel" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户Logo</label>
            <div class="layui-input-block">
                <input type="text" name="ClientLogo"  autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人</label>
            <div class="layui-input-block">
                <input type="text" name="Contact" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人电话</label>
            <div class="layui-input-block">
                <input type="text" name="ContactTel"  autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人邮箱</label>
            <div class="layui-input-block">
                <input type="text" name="ContactEmail"  autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">社会信用代码</label>
            <div class="layui-input-block">
                <input type="text" name="CreditCode"  autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">客户备注</label>
            <div class="layui-input-block">
                <textarea name="Remark"  placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" type="button" lay-submit lay-filter="addClient">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </form>

    <script>
        layui.use(['form', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
            $ = layui.$;

            // 提交事件
            form.on('submit(addClient)', function (data) {
                data = data.field;
               
              

                $.get("/QiData/AddClient", data,
                    res => {
                        console.log(res);
                        if (res) {
                            console.log(res);
                            layer.msg('添加成功', {
                                icon: 1,
                                time: 1000
                            }, function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                cation.href = '/QiData/Mdclient';
                            });
                        }
                        else {
                            layer.msg('添加失败！', {
                                icon: 1,
                                time: 1000
                            });
                        }
                    }
                )
              
                 
        });
            
            $('#test-btn-other').on('click', function () {
                var index = "1234567890";
                var num = "";
                for (var i = 0; i < 5; i++) { // 循环10次
                    // 生成一个五位数的随机数
                    var randomFiveDigitNumber = Math.floor(Math.random() * index.length);
                    num += index[randomFiveDigitNumber]
                }
                var codes = "C" + num;
                $("[name=ClientCode]").val(codes);
                return false;
            });
        });
        
    </script>
</body>
</html>
